(C) 1996 AROS - The Amiga Replacement OS


NAME
#include <stdlib.h>
unsigned long strtoul()
SYNOPSIS
const char * str
char ** endptr
int base

FUNCTION
Convert a string of digits into an integer according to the given base.

INPUTS
str
The string which should be converted. Leading whitespace are ignored. The number may be prefixed by a '+' or '-'. If base is above 10, then the alphabetic characters from 'A' are used to specify digits above 9 (ie. 'A' or 'a' is 10, 'B' or 'b' is 11 and so on until 'Z' or 'z' is 35).
endptr
If this is non-NULL, then the address of the first character after the number in the string is stored here.
base
The base for the number. May be 0 or between 2 and 36, including both. 0 means to autodetect the base. strtoul() selects the base by inspecting the first characters of the string. If they are "0x", then base 16 is assumed. If they are "0", then base 8 is assumed. Any other digit will assume base 10. This is like in C. If you give base 16, then an optional "0x" may precede the number in the string.
RESULT
The value of the string. The first character after the number is returned in *endptr, if endptr is non-NULL. If no digits can be converted, *endptr contains str (if non-NULL) and 0 is returned.

NOTES
EXAMPLE
// Returns 1, ptr points to the 0-Byte
strtoul ("  \t +0x1", &ptr, 0);

// Returns 15. ptr points to the a
strtoul ("017a", &ptr, 0);

// Returns 215 (5*36 + 35)
strtoul ("5z", &ptr, 36);

BUGS
SEE ALSO
labs(), fabs(), strtol()
INTERNALS
HISTORY
23.04.1997 aros
Initialized some variables that could have caused problems otherwise
14.03.1997 digulla
Forgot to advance the string pointer AGAIN :-((
12.12.1996 aros
New functions